package com.sie.plm.rpm.standar.controller.project;

import com.alibaba.fastjson.JSON;
import com.hustcad.plm.rpm.model.vo.admin.ProjectVO;
import com.hustcad.plm.rpm.util.response.ResponseResult;
import com.sie.plm.rpm.standar.service.project.StandarProjectService;
import com.sie.plm.rpm.standar.vo.ProjectIbaVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@RestController
@Api(tags = {"标准版创建项目同步iba属性到产品库"})
@RequestMapping({"/api/v1/standar/project"})
public class StandarProjectController {

    private static final Logger log = LoggerFactory.getLogger(StandarProjectController.class);

    @Autowired
    private StandarProjectService standarProjectService;


    @PutMapping({"/standarCreatProject"})
    @ApiOperation(value = "标准版创建项目", produces = "application/json; charset=utf-8")
    public ResponseResult<ProjectVO> standarCreatProject(@Valid @RequestBody ProjectVO project) {
        log.info("standarCreatProject request Param {}", JSON.toJSONString(project));
        return ResponseResult.success(this.standarProjectService.creatStandarProject(project));
    }


    @PostMapping({"/saveObjIBAInfo"})
    @ApiOperation(value = "标准版创建项目同步iba属性到产品库", produces = "application/json; charset=utf-8")
            public ResponseResult<Boolean> saveObjIBAInfo(@RequestBody ProjectIbaVO projectIbaVO) {
        log.info("saveObjIBAInfo request Param {}", JSON.toJSONString(projectIbaVO));
        this.standarProjectService.saveObjIBAInfo(projectIbaVO);
        return ResponseResult.success(Boolean.valueOf(true));
    }

    @PostMapping({"/updateObjIBAInfo"})
    @ApiOperation(value = "标准版更新项目同步iba属性到产品库", produces = "application/json; charset=utf-8")
            public ResponseResult<Boolean> updateObjIBAInfo(@RequestBody ProjectIbaVO projectIbaVO) {
        log.info("updateObjIBAInfo request Param {}", JSON.toJSONString(projectIbaVO));
        this.standarProjectService.updateObjIBAInfo(projectIbaVO);
        return ResponseResult.success(Boolean.valueOf(true));
    }

}
